<?php

namespace App\Http\Requests\WebPage;

use App\Exceptions\AdminManageException;
use App\Services\BymAdmin\AdminErrCode;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest;

class WebPageApiRequest extends FormRequest
{
    protected function failedValidation(Validator $validator)
    {
        throw new AdminManageException( AdminErrCode::REQUEST_FAILED_PASS_VALIDATE,
            $this->formatErrors($validator)
        );
    }

    /**
     * Handle a failed authorization attempt.
     *
     * @return void
     *
     * @throws AdminManageException
     */
    protected function failedAuthorization()
    {
        throw new AdminManageException( AdminErrCode::ADMIN_AUTH_NOT_FOUND, '请求方访问受限');
    }
}
